package com.liujit.standard.basis.core.config;


import cn.hutool.crypto.SecureUtil;
import com.liujit.standard.basis.core.constants.HeaderConstants;
import feign.RequestInterceptor;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @description: FeignClient发起的请求添加请求头
 * @author: liujun
 * @create: 2021/3/24 5:30 下午
 **/
@Configuration
public class FeignHeaderConfig {
    @Bean
    public RequestInterceptor headerInterceptor() {
        return template -> {
            Long millis = System.currentTimeMillis();
            String value = SecureUtil.md5(HeaderConstants.FEIGN_CLIENT_HEADER_VALUE + millis);
            template.header(HeaderConstants.FEIGN_CLIENT_HEADER_NAME, value + "/" + millis);
        };
    }
}
